<template>
	<view>
		<view class="top">
			<view style="text-align: center; font-size: 35rpx; color: #fff;">欢迎来到车联网服务平台商家端</view>
			<view style=" height: 200rpx;"></view>
			<view style="border-radius: 20px; background-color: #fff; padding: 150rpx 50rpx 0 50rpx;">
				<image src="/static/yellowman.png" style="width: 300rpx; height: 200rpx; position: fixed; top: 150rpx; left: 240rpx;"></image>
				<view style="font-weight: 600; margin: 0 10rpx; padding-left: 20rpx;"><input type="text" placeholder="手机号登陆" v-model="phone" /></view>
				<view style="width: 100%; height: 1px; background-color: gray; margin: 20px 10px;"></view>
				<view style="font-weight: 600; margin: 0 10rpx; padding-left: 20rpx; display: flex; justify-content: space-between; align-items: center;"><input type="text" placeholder="输入验证码" v-model="yanzhengma"  style="width: 400rpx;" /><text @click="getYan()" style="font-size: 16rpx; border-radius: 30px; color: #e6e6e6; background-color: #4c8efe; padding: 5px 10px;">获取验证码</text></view>
				<view style="width: 100%; height: 1px; background-color: gray; margin: 20px 10px;"></view>
				<text style="color: #4c8efe; margin: 0 20px;" @click="toRegister()">立即注册></text>
				<button style="background-color: #4c8efe; color: #e6e6e6; margin: 0 20px; margin-top: 50rpx; border-radius: 30px;" @click="login()">登录</button>
			</view>
		</view>
		
	</view>
</template>

<script setup>
	import {onLoad} from "@dcloudio/uni-app"
	import request from "@/utils/request.js"
	import { ref } from "vue"
	function login(){
		request({
			url:"/auth/loginBySms",
			method:"GET",
			data:{
				phoneNumber:phone.value,
				code:yanzhengma.value,
				key:key.value
			},
			success:(res)=> {
				console.log(res.data)
				uni.setStorageSync("token",res.data.data.access_token)
				request({
					url:"/yyq/verification/selectbymobile/"+phone.value,
					method:"GET",
					success: (res) => {
						console.log(res.data)
						uni.setStorage({
							"key":'info',
							"data":res.data.data
						})
					}
				}),
				uni.navigateTo({
					url:"/pages/index/index"
				})
			}
		})
		
		
		
	}
	//获取商家认证信息
	function getoken(){
		uni.getStorage({
			key:"info",
			success: (res) => {
				console.log(res)
			}
		})
	}
	const key=ref("")
	const yanzhengma=ref("")
	const phone=ref("17837080612")
	function toRegister(){
		uni.navigateTo({
			url:'/pages/register/register'
		})
	}
	function toIndex(){
		uni.redirectTo({
			url:'/pages/index/index'
		})
	}
	function getYan(){
		uni.request({
			url:"/api/auth/sendSms",
			method:"GET",
			data:{
				phoneNumber:phone.value
			},
			success:(res)=> {
				key.value=res.data.data
			}
		})
	}
	
</script>

<style>
@import "../../common/app.css";	

	       
</style>
